<script setup lang="ts">
import { ref, watch } from 'vue';

const props = defineProps<{
    modelValue: string;
}>();

const emit = defineEmits(['update:modelValue']);

const answer = ref(props.modelValue);

const updateAnswer = (value: string) => {
    answer.value = value;
    emit('update:modelValue', value);
};

watch(() => props.modelValue, (newValue) => {
    answer.value = newValue; // 同步更新答案
});
</script>

<template>
    <van-radio-group v-model="answer" @change="updateAnswer">
        <van-cell-group inset>
            <van-cell>
                <template #title>
                    <van-radio name="true">正确</van-radio>
                </template>
            </van-cell>
            <van-cell>
                <template #title>
                    <van-radio name="false">错误</van-radio>
                </template>
            </van-cell>
        </van-cell-group>
    </van-radio-group>
</template>